﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DCS7GUI
{
    public class GUIRWinButtons : IDCSGUI
    {
        public byte X
        {
            get
            {
                return 0;
            }
            set
            {
            }
        }
        public byte Y
        {
            get
            {
                return 0;
            }
            set
            {
            }
        }
        public byte Width
        {
            get
            {
                return 0;
            }
            set
            {
            }
        }
        public byte Height
        {
            get
            {
                return 0;
            }
            set
            {
            }
        }
        public bool Close { get; set; }
        public bool Minimize { get; set; }
        public bool Maximize { get; set; }
        public string OnClose { get; set; }
        public string OnMinimize { get; set; }
        public string OnMaximize { get; set; }

        #region IDCSGUI Members

        public byte Size
        {
            get
            {
                return 10;
            }
        }

        public byte Type
        {
            get
            {
                return 5;
            }
        }

        public string Data
        {
            get
            {
                byte value = (byte)((Minimize ? 0x20 : 0) | (Maximize ? 0x40 : 0) | (Close ? 0x80 : 0));
                return Helpers.BytesToHex(new byte[] { value }) + "\n" +
                    OnMinimize + "\n" +
                    OnMaximize + "\n" +
                    OnClose + "\n";
            }
        }

        public System.Drawing.Bitmap Render(System.Drawing.Bitmap image, int offsetX, int offsetY)
        {
            if (Parent is GUIRLargeWin)
            {
                Helpers.DrawSprite(88, 1, new byte[] { 0x7C, 0x82, 0xAA, 0x92, 0xAA, 0x82, 0x7C, }, image);
                int x = 88;
                if (Close)
                {
                    Helpers.DrawSprite(x, 1, new byte[] { 0x7C, 0x82, 0xAA, 0x92, 0xAA, 0x82, 0x7C, }, image);
                    x -= 6;
                }
                else
                {
                    if (Maximize || Minimize)
                        Helpers.DrawSprite(x + 2, 1, new byte[] { 0x0, 0x8, 0x8, 0x8, 0x8, 0x8, }, image);
                }
                if (Maximize)
                {
                    Helpers.DrawSprite(x, 1, new byte[] { 0x7C, 0x80, 0xB8, 0xA8, 0xB8, 0x80, 0x7C, }, image);
                    x -= 6;
                }
                if (Minimize)
                {
                    Helpers.DrawSprite(x, 1, new byte[] { 0x7C, 0x80, 0x80, 0x80, 0xB8, 0x80, 0x7C, }, image);
                    x -= 6;
                }
            }
            else if (false) // GUIRSmallWin
            {
            }
            else
            {
            }
            return image;
        }

        public IGUIContainer Parent { get; set; }

        #endregion
    }
}
